<!-- components/evaluate-components/index.wxml -->
<template>
	<view class="evaluateBox">
		<view class="evaluate-header">
			<view class="title">
				<text class="iconfont" style="color:#fa436a">&#xe640;</text>
				<text style="margin-left: 10upx;">评价 ({{getCount}})</text>
			</view>
			<view class="total">
				<text>好评率：{{ goodsString }}</text>
			</view>
		</view>

		<view class="lists" v-if="listData.length > 0">
			<block v-for="(item, index_) in listData" :key="index_">
				<view class="item">
					<!-- 用户头像 -->
					<view class="icon"><image :src="item.userAvatar" mode="widthFix" style="width:100%" /></view>
					<view class="info">
						<view class="name-time">
							<!-- 昵称，时间 -->
							<text class="name">{{ item.userid }}</text>
							<text class="time">{{ item.addtime }}</text>
						</view>
						<view class="stars">
							<view class="stars-normal">
								<view class="box">
									<block v-for="i_ in 5" :key="i_"><text class="iconfont">&#xe870;</text></block>
								</view>
							</view>
							<view class="stars-selected" :style="{ width: (item.star / 5) * 100 + '%' }">
								<view class="box">
									<block v-for="j_ in 5" :key="j_"><text class="iconfont">&#xe870;</text></block>
								</view>
							</view>
						</view>
						<view class="evaluate-content">
							<text>{{ item.content || '用户暂未评价' }}</text>
							<view class="imgs" v-if="item.picurls">
								<block v-for="(picurls, index) in item.picurls" :key="index">
									<view class="imgs-box"><image :src="picurls" mode="widthFix" style="width: 100%;" @click="previewImg(picurls,item.picurls)"></image></view>
								</block>
							</view>
						</view>
						<view class="specifications">
							<text class="">规格：{{ item.specifications }}</text>
						</view>
					</view>
				</view>
			</block>
		</view>
		<view class="no-lists" v-else>暂无评论</view>
        <!-- <view class="comment" @click="addComment()">
			<view class="comment-ch">
				发表评论
			</view>
		</view> -->
	</view>
</template>

<script>
//数据模拟
// import data from './list.js';
export default {
	props: {
		//评价列表数据
		listData: {
			type: Array,
			default: []
		},
		//是否显示总评价数量
		isShowTotal: {
			type: Boolean,
			default: true
		},
		//是否显示评价前面的图标
		isShowIcon: {
			type: Boolean,
			default: true
		},
		//总评分
		rate: {
			type: Number,
			default: 4.6
		},
		//总条数
		getCount: {
			type:String,
			default:'0'
		},
		//好评率
		goodsString: {
			type:String,
			default:"100%"
		}
		
	},
	data() {
		return {
			
		}
	},
	onLoad() {
		
	},
	methods: {
		//图片点击放大事件
		previewImg(src,urls){
			uni.previewImage({
				current:src,
				urls
			})
		},
		//触发父组件事件
		addComment(){
			this.$parent.addComment();
		}
	}
};
</script>
<style scoped>
@import './iconfont.css';

.comment{
	border: 1px solid red;
	position: fixed;
	right:0;
	bottom:0;
	height: 100upx;
	width: 100%;
	background-color:#fa436a;
	/* margin-bottom: 50upx;
	margin-right: 50upx; */
	font-size:35upx;
	color: #EEEEEE;
}


.comment-ch{
	display: flex;
    justify-content: center;
    align-items: center;
	margin-top: 25upx;
}



.evaluateBox {
	width: 100%;
	margin-bottom: 120upx;
}

.evaluate-header {
	width: 100%;
	height: 80upx;
	display: flex;
	justify-content: space-between;
	padding: 20upx;
	align-items: center;
	margin-bottom: 12upx;
	box-sizing: border-box;
	border-bottom: 1upx solid #e5e5e5;
}

.evaluateBox .title {
	display: flex;
	align-items: center;
	color: #000000;
	font-size: 30upx;
}


.total {
	/* flex: 1; */
	height: 100%;
	font-size: 30upx;
	font-weight: 600;
	color: #fa436a;
	display: flex;
	align-items: center;
	justify-content: flex-end;
}

.stars {
	width: 180upx;
	height: 36upx;
	position: relative;
}
.stars .box {
	width: 180upx;
}
.stars-normal {
	width: 100%;
	position: absolute;
	left: 0;
	top: 0;
	color: #ccc;
}
.stars-selected {
	position: absolute;
	left: 0;
	top: 0;
	z-index: 1;
	color: #fde16d;
	overflow: hidden;
}

.stars-selected .iconfont{
	color: #fa436a;
}
.stars-selected .iconfont,
.stars-normal .iconfont {
	font-size: 36upx;
}


.lists .item {
	padding: 25upx;
	display: flex;
	/* height: auto; */
	/* align-items: center; */
	font-size: 22upx;
	color: #999;
	/* border-bottom-style:solid;
	border-top-color: #666666; */
	border-bottom:1px solid #C0C4CC ;
	
}

.lists .item .icon {
	width: 60upx;
	height: 60upx;
	border-radius: 50%;
	overflow: hidden;
	margin-right: 26upx;
	/* align-self: flex-start; */
	
}

.lists .item .info {
	flex: 1;
	font-size: 26upx;
	color: #666;
}

.info .name-time {
	display: flex;
	align-items: center;
	justify-content: space-between;
	padding-bottom: 6upx;
}

.info .specifications{
	display: flex;
	align-items: center;
	justify-content: space-between;
	padding-top: 25upx;
}
.lists .info .stars {
	width: 140upx;
}

.info .stars-normal .iconfont{
	color:#C0C4CC;
}

.info .stars-normal .iconfont,
.info .stars-selected .iconfont {
	
	font-size: 28upx;
}

.info .stars .box {
	width: 140upx;
}
.lists .info .evaluate-content {
	color: #000;
	font-size: 28upx;
	text-align: left;
	padding-top: 6upx;
}
.info .evaluate-content .imgs {
	display: flex;
	flex-wrap: wrap;
	padding-top:25upx;
}
.evaluate-content .imgs .imgs-box {
	width: 25%;
	padding-right: 10upx;
	box-sizing: border-box;
}
/* .evaluate-content .imgs .imgs-box:nth-child(4n+1){
	padding-left: 0;
}
.evaluate-content .imgs .imgs-box:nth-child(4n){
	padding-right: 0;
} */
.no-lists {
	padding: 20upx 0;
	text-align: center;
	font-size: 24upx;
	color: #666;
}
</style>
